home *** CD-ROM | disk | FTP | other *** search
-
- /* Simple Trecker.c */
-
- /* Demonstrationsprogramm für die Anwendung der 'PSyn'- und die 'STrI'-Resource. */
-
- /* Program to demonstrate the use of the 'PSyn' and 'STrI' resources. */
-
- /*
- Copyright (c) 1992 by
- Frank Seide
- Koolbarg 39d
- D-2000 Hamburg 74
- Germany
- */
-
- /*
- Die 'PSyn'- und die 'STrI'-Resource sowie dieser Beispielquelltext dürfen gerne
- in Public-Domain-Software unter folgenden Bedingungen kostenlos verwendet werden:
- • die Musikroutinen sind nicht frei von Uhrheberrechten. Daher muß
- sich im Public-Domain-Programm und in der Dokumentation ein Hinweis auf das
- Copyright der beiden Resourcen unter Angabe meiner Adresse befinden;
- • ein Exemplar des Programms wird mir zugeschickt;
- • die Resourcen dürfen nicht verändert werden (entdeckte Bugs bitte mir mitteilen;
- ich werde sie dann beheben. Es ist wichtig, einen Versionswildwuchs zu vermeiden);
- • eine kommerzielle Nutzung ist nur nach meiner ausdrücklichen, schriftlichen
- Zustimmung zulässig, sonst nicht.
- */
-
- /*
- The 'PSyn' and 'STrI' resources as well as this example source code may be used
- freely in public domain programs under the following conditions:
- • the resources themselves are copyrighted and not in the public domain!
- The public domain program and the documentation must contain a copyright notice
- like above, my address must be mentioned;
- • you must send me one copy of the program;
- • the code resources may not be modified (if you should find a bug, please tell me
- to fix it. It´s important not to have too many different versions of the code);
- • any kind of commercial use is forbidden and requires a special license aggreement.
- */
-
- #include <stdio.h>
- #include <sound.h>
- #include "PSyn.h"
- #include "STrI.h"
-
- main()
- {
- /* Das Programm benötigt den Sound-Manager von System 7 (den enthält auch System */
- /* 6.0.7) und einen MC68020 (oder höher). Die 'PSyn'-Resource überprüft dies beim */
- /* Öffnen des Sound-Kanals. Es ist jedoch sinnvoll, diese Überprüfung am Anfang */
- /* des Hauptprogramms selbst durchzuführen (wird in diesem Beispiel nicht getan). */
-
- /* The program requires the sound manager of System 7 (contained in System 6.0.7 */
- /* and above) and a MC68020 (or higher). The 'PSyn' code performs a check before */
- /* opening the sound channel. You may want to do this check in the main program
- /* (not shown in this example). */
-
- /* Variablen / Variables: */
- int i;
- struct PChannel * pc = NULL; /* Pointer */
- struct SoundTrack ** strk = NULL; /* Handle! */
-
- /* Konstanten / Constants: */
- Boolean stereo = FALSE; /* Stereo ? */
- Boolean fadeOut = TRUE; /* Beim Stoppen ausblenden / fade out on stop ? */
-
- /* Initialisierungen / Initializations: */
-
- InitGraf (&thePort);
- InitFonts();
- FlushEvents (everyEvent, 0);
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs (NULL);
- InitCursor();
-
- /* Soundkanal öffnen / Open the sound channel: */
- if (OpenPChannel (CHANNELS, stereo, 445*2, &pc)) { SysBeep (30); exit(); }
-
- /* Wiedergabeabtastrate auf 22 kHz setzen (Default; nur zur Demonstration): */
- /* Change output sampling rate to 22 kHz (default; just to demonstrate): */
- pc->softFreq = pc->hardFreq = rate22khz;
-
- /* Maximale Lautstärke für die 4 Stimmen, 50% Gesamtlautstärke: */
- /* Maximum volume for the four voices, 50% total volume: */
- for (i = 0; i < 4; i++) PChannelVolume (pc, i, 0x10000);
- PChannelVolume (pc, -1, 0x08000); /* -1 = Gesamtlautstärke / Total volume */
-
- /* Hauptschleife / Main Loop: */
- while (TRUE) {
-
- /* Open-Dialog präsentieren / Show open dialog: */
- Point openPoint = { 85, 100 };
- SFTypeList theTypeList = { 'STrk' };
- SFReply theReply;
-
- SFGetFile (openPoint, "\p", NULL, 1, theTypeList, NULL, &theReply);
- if (!theReply.good) { StopPChannel (pc, fadeOut); break; }
-
- /* Laufenden SoundTrack abschalten / Stop currently playing SoundTrack: */
- if (strk) {
- StopPChannel (pc, fadeOut); /* Stoppen / stop playing */
- UnlinkSoundTrack (strk); /* STrk abtrennen / Unlink STrk from chan */
- DisposeSoundTrack (strk); /* Speicher freigeben / free memory */
- strk = NULL;
- }
-
- /* Neuen SoundTrack laden / Load next SoundTrack: */
- if (GetSoundTrack (theReply.vRefNum, theReply.fName, 0, &strk, FALSE))
- SysBeep (30);
- else {
- /* SoundTrack-Optionen einstellen / Change SoundTrack options: */
- (*strk)->musicRecord.loopDetect = TRUE;
-
- /* Soundtrack mit Kanal verbinden / Link STrk to sound channel: */
- LinkSoundTrack (strk, pc);
-
- /* Kanaloptionen setzen / Change channel options: */
- pc->antiAlias = TRUE;
- PChannelVolume (pc, -1, 0x08000); /* Nötig! / Necessary due to fadeOut */
-
- /* Stück von vorne spielen / Play SoundTrack from start: */
- ResetPChannel (pc);
- if (StartPChannel (pc)) { SysBeep (30); break; }
- }
- }
-
- /* Soundkanal schließen (unbedingt nötig bei System 6.0.7!): */
- /* Close the sound channel (necessary on System 6.0.7!): */
- ClosePChannel (pc);
- }
-
-